package com.LeeCode;

/**
 * 子数组异或查询
 */

public class Code1310 {
    public static void main(String[] args) {

    }

    public int[] xorQueries(int[] arr, int[][] queries) {
        int[] ans = new int[queries.length], preXor = new int[arr.length + 1];
        for (int i = 0; i < arr.length; i++) {
            preXor[i + 1] = preXor[i] ^ arr[i];
        }

        for (int i = 0; i < queries.length; i++) {
            int left = queries[i][0], right = queries[i][1];
            ans[i] = preXor[left] ^ preXor[right + 1];
        }
        return ans;
    }
}
